package com.lzm.springcloud.Config;

import com.lzm.myrule.MyRandomRule;
import com.netflix.loadbalancer.IRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: TODO
 * @author: lzm
 * @date: 2021年04月22日 18:24
 */
@Configuration  //spring application.xml
public class ConfigBean {
    //IRule
    @LoadBalanced //配置负载均衡实现RestTemplate
    @Bean
    public RestTemplate getRestTemplate()
    {
        return new RestTemplate();
    }

    @Bean
    public IRule myRule()
    {
        return new MyRandomRule();//默认是轮询RandomRule,现在自定义为自己的
    }
}
